package com.ikas.ai.server.config.handler;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;

import java.util.List;

/**
 * @Description: 字符串 <-> list<Long>
 * @Author: qi.yilai
 * @Date: 2023/4/11 19:08
 * @Version: 1.0.0
 **/
@MappedTypes({Object.class})
@MappedJdbcTypes({JdbcType.VARCHAR})
public class ListLongHandler extends AbstractJsonTypeHandler<List<Long>> {
    @Override
    protected List<Long> parse(String json) {
        return JSON.parseArray(json, Long.class);
    }

    @Override
    protected String toJson(List<Long> obj) {
        return JSON.toJSONString(obj);
    }
}
